﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using DB.Model;

namespace HR_ASP.ViewModel
{
    public class DzialStanowViewModel
    {
        public int ID { get; set; }
        public int? IDDzial { get; set; }
        public int? IDStan { get; set; }

        public Dzial Dzial { get; set; }
        public StanowiskoViewModel Stanowisko { get; set; }
        public DzialViewModel[] Dzialy { get; set; }
        public StanowiskoViewModel[] Stanowiska { get; set; }


        public DateTime DataU { get; set; }
        public DateTime DataM { get; set; }


        public DzialStanowViewModel()
        {
        }

        public DzialStanowViewModel(Dzial_Stan dzialStan)
        {
            this.ID = dzialStan.ID_DzS;
            this.IDDzial = dzialStan.ID_Dzial;
            this.IDStan = dzialStan.ID_Stan;
            this.DataM = (DateTime)dzialStan.DataM;
            this.DataU = (DateTime)dzialStan.DataU;
        }

        public Dzial_Stan getModel(Dzial_Stan dzialStan)
        {
            dzialStan.ID_DzS = (int)this.ID;
            dzialStan.ID_Dzial = (int)this.IDDzial;
            dzialStan.ID_Stan = (int)this.IDStan;
            if (this.ID == 0)
            {
                dzialStan.DataU = DateTime.Now;
            }
            dzialStan.DataM = DateTime.Now;
            return dzialStan;
        }
    }
}